Skip to content

HDDS-15175. Introduce StorageClass and storage policy#10191

Open
xichen01 wants to merge 5 commits intoapache:HDDS-11233from
xichen01:HDDS-15175
Open

HDDS-15175. Introduce StorageClass and storage policy#10191
xichen01 wants to merge 5 commits intoapache:HDDS-11233from
xichen01:HDDS-15175

Conversation

@xichen01
Copy link
Copy Markdown
Contributor

@xichen01 xichen01 commented May 5, 2026

What changes were proposed in this pull request?

Introduce StorageClass and storage policy, introducing storage policy related definitions

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15175

How was this patch tested?

unit test

Copy link
Copy Markdown
Contributor

@chungen0126 chungen0126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xichen01 for the patch. Overall, looks good to me, but I have a few minor suggestions.

return StoragePolicyProto.COLD;
default:
throw new IllegalArgumentException(
"Error: StoragePolicyType not found, type=" + this);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The class name is OzoneStoragePolicy.

Suggested change
"Error: StoragePolicyType not found, type=" + this);
"Error: OzoneStoragePolicy not found, type=" + this);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

if (storageTypes.isEmpty()) {
return Collections.emptyList();
}
return new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider making the StorageType list read-only to ensure immutability?

Suggested change
return new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0)));
return Collections.unmodifiableList(new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0)));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +64 to +69
if (Arrays.stream(storageTypes).distinct().count() <= 1) {
throw new IllegalArgumentException("StorageTier '" + tierName +
"' requires at least two different StorageType instances." +
" but only " + Arrays.stream(storageTypes).distinct().count() +
" StorageType were provided.");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand that non-uniform storage tiers aren't supported yet (so this line might not be reachable), Arrays.stream(storageTypes).distinct().count() is called twice here. We could assign it to a variable instead.

Suggested change
if (Arrays.stream(storageTypes).distinct().count() <= 1) {
throw new IllegalArgumentException("StorageTier '" + tierName +
"' requires at least two different StorageType instances." +
" but only " + Arrays.stream(storageTypes).distinct().count() +
" StorageType were provided.");
}
long distinctStorageTypes = Arrays.stream(storageTypes).distinct().count();
if (distinctStorageTypes <= 1) {
throw new IllegalArgumentException("StorageTier '" + tierName +
"' requires at least two different StorageType instances." +
" but only " + distinctStorageTypes +
" StorageType were provided.");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, non-uniform storage tiers are not currently supported; this is merely a reserved interface.

import org.apache.hadoop.hdds.client.StorageTier;
import org.junit.jupiter.api.Test;

class StoragePolicyTest {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some unit tests to cover the Protobuf/Java conversion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test for this

* Ozone specific storage tiers.
*/
public enum StorageTier {
SSD("SSD", StorageType.SSD),
Copy link
Copy Markdown
Contributor

@greenwich greenwich May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we may introduce the NVME storage type (here and below where it's needed)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it depends on the actual needs. If you need to differentiate between regular low-speed SATA/SAS SSDs and high-speed NVMe SSDs, you can add an NVMe SSD.

You can create a subtask in https://issues.apache.org/jira/browse/HDDS-11233, and then we can submit a separate PR to add this NVME storage type.

FYI: Since the subsequent code is based on the current storage types, it is recommended to add this feature later; otherwise, it may introduce some conflicts.

@greenwich
Copy link
Copy Markdown
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants